package com.menhai.personmanagement.services;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.menhai.personmanagement.entity.MbTreatmentInformation;
import com.menhai.personmanagement.mapper.MbTreatmentInformationMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 就诊信息 服务类
 * </p>
 *
 * @author shikun
 * @since 2022-05-07
 */
 @Service
public class IMbTreatmentInformationService{

   @Autowired
   private MbTreatmentInformationMapper mbTreatmentnformationMapper;


   /**
    * @describe 新增就诊信息
    * @param mbTreatmentInformation
    * @Return int
    * @Date 2022/5/7 14:27
    * @author shikun
    */
    public int addinformation(MbTreatmentInformation mbTreatmentInformation){
        return mbTreatmentnformationMapper.insert(mbTreatmentInformation);
    }

    /**
     * @describe 根据id 删除信息
     * @param mbTreatmentInformation
     * @Return int
     * @Date 2022/5/7 14:28
     * @author shikun
     */
    public int deleteByIdinformation(MbTreatmentInformation mbTreatmentInformation){
        return mbTreatmentnformationMapper.deleteById(mbTreatmentInformation);
    }

    /**
     * @describe 根据村民id 查询就诊信息
     * @param mbTreatmentInformation
     * @Return java.util.List
     * @Date 2022/5/7 14:28
     * @author shikun
     */
    public List listmbTreatmentnformation(MbTreatmentInformation mbTreatmentInformation){

        QueryWrapper wrapper = new QueryWrapper();
        if (null != mbTreatmentInformation.getHospital() && !mbTreatmentInformation.getHospital().equals("")) {
            wrapper.eq("hospital", mbTreatmentInformation.getHospital());
        }
        if (null != mbTreatmentInformation.getDisease() && !mbTreatmentInformation.getDisease().equals("")) {
            wrapper.eq("disease", mbTreatmentInformation.getDisease());
        }
        if (null != mbTreatmentInformation.getTherapyprocess() && !mbTreatmentInformation.getTherapyprocess().equals("")) {
            wrapper.eq("therapyprocess", mbTreatmentInformation.getTherapyprocess());
        }
        if (null != mbTreatmentInformation.getDoctor() && !mbTreatmentInformation.getDoctor().equals("")) {
            wrapper.eq("doctor", mbTreatmentInformation.getDoctor());
        }
        if (null != mbTreatmentInformation.getMedicine() && !mbTreatmentInformation.getMedicine().equals("")) {
            wrapper.eq("medicine", mbTreatmentInformation.getMedicine());
        }
        if (null != mbTreatmentInformation.getPopulation() && !mbTreatmentInformation.getPopulation().equals("")) {
            wrapper.eq("population", mbTreatmentInformation.getPopulation());
        }
        return mbTreatmentnformationMapper.selectList(wrapper);
    }

    public MbTreatmentInformation selectByIdinformation(MbTreatmentInformation mbTreatmentInformation){
        return mbTreatmentnformationMapper.selectById(mbTreatmentInformation.getId());
    }
}
